Mybatis 之 xml 中日期时间段查询的 sql 语句

作者: 李多多 日期: 2020-04-30

Mybatis 之 xml 中日期时间段查询的 sql 语句

< if test=”startDate!=null and startDate!=’’” > and CREATEDATE >=#{startDate} < /if>
< if test=”endDate!=null and endDate!=’’” > and CREATEDATE <=#{endDate}< /if>

日期字段存入数据库都是字符串,不是 date 型,xml 中 >,< 不能被正确解析,所以需要 XML 转义字符。